<template>
	<view>
		<view class="tui-actionsheet" :class="[show ? 'tui-actionsheet-show' : '']" >
			<view class="regional-selection">
				<view class="specs" style="display: flex; flex-direction: column;justify-content:center;align-items: center;text-align: center;" >
				   
				    <view  class="specs-top-desc mt-10" style="display: flex; margin-top: 20rpx;">处方信息</view>
				    <view class="specs-top-desc" style="font-size: 25rpx; margin-left:20rpx;margin-right: 20rpx; display: flex;flex-direction: column;width: 80%	;">
					    <view class="flex mt-10" style="display: flex;margin-top: 30rpx;">
							<text style="display: flex;width: 200rpx;">患者名：</text><input type="text" v-model="patient_name" class="flex-1 rounded bg-light ml-2" style="padding: 5rpx;" :focus="focus" placeholder="请输入患者名称"/></view>
				    	  <view class="flex mt-10" style="display: flex;margin-top: 30rpx;">
				    		<text style="display: flex;width: 200rpx;">医生名：</text><input type="text" v-model="doctor_name" class="flex-1 rounded bg-light ml-2" style="padding: 5rpx;" :focus="focus" placeholder="请输入医生名称"/></view>
						  <view class="flex mt-10" style="display: flex;margin-top: 30rpx;">
							<text style="display: flex;width: 200rpx;">患者症状：</text><input type="text" v-model="symptom" class="flex-1 rounded bg-light ml-2" style="padding: 5rpx;" :focus="focus" placeholder="请输入患者症状"/></view>
					      <view class="flex mt-10" style="display: flex;margin-top: 30rpx;">
							<text style="display: flex;width: 200rpx;">处方药：</text>							
							<textarea 
							class="flex-1 rounded bg-light ml-2"  style="height: 200rpx;" v-model="drugs" placeholder="请输入处方药信息" :focus="focus" ></textarea>
						</view>											
					    <view>
						   <button class="submit-btn-right" style="background: #2B91ED;" @click.stop="confirm_order()">提交</button>
					    </view>		
									   
				    </view>				    
				</view>
			</view>
		</view>
		<!-- 遮罩层 -->
		<view class="tui-actionsheet-mask"  :class="[show ? 'tui-mask-show' : '']"  @tap="handleClickMask"></view>
	</view>
</template>
 
<script>
	import $http from '@/common/request.js';
export default {
  // name: "tuiActionsheet",
  props: {
    //点击遮罩 是否可关闭
    maskClosable: {
      type: Boolean,
      default: true,
    },
    //显示操作菜单
    show: {
      type: Boolean,
      default: false,
    },
  },
  data () {
  	return {
  		patient_name:'',    
  		doctor_name:'',
  		symptom: '',
  		drugs:'',
		ToUser:{}
  	}  
  },
methods:  {
   
    handleClickMask() {
		 this.$emit("chooseCancel",false);
    },
	
	showGoods(event){
		this.ToUser=event
	},
	
	confirm_order(){
		let obj_data={
			patient_name:this.patient_name,
			doctor_name:this.doctor_name,
			symptom:this.symptom,
			drugs:this.drugs,	
			userId:this.ToUser.user_id,
		    doctor_id:uni.getStorageSync('userid')
				
		}
		if(!obj_data.patient_name){
			this.$utils.msg('请输入患者名称！')
			return
		} 
		
		if(!obj_data.doctor_name){
			this.$utils.msg('请输入医生名称！')
			return
		}
		
		if(!obj_data.symptom){
			this.$utils.msg('请输入患者症状！')
			return
		}
        
		if(!obj_data.drugs){
			this.$utils.msg('请输入处方药信息！')
			return
		}		
		console.log('oi',obj_data)
		$http.post('api/contact', obj_data, {
		    token: true
		}).then(data => {
			console.log('data',data)
			if(data.statusCode==200){
				this.$emit("applayCancel",obj_data);
				this.patient_name=''
				this.doctor_name=''
				this.symptom=''
				this.drugs=''
			}else{
				this.$emit("chooseCancel",false);
			}
		}).catch(err => {
		    // 失败 退出登录，重新链接等处理
		})	
			
		
	}
    
   
  },
};
</script>
 
<style scoped lang="less">
	
	.submit-btn-right {
	  display: flex;
	  align-items: center;
	  justify-content: center;
	  color: #FFF;
	  min-width: 240rpx;
	  width: 100%;
	  height: 76rpx;
	  opacity: 1;
	  border-radius: 38rpx;
	  margin-top: 10rpx;
	}
	
	
.tui-actionsheet {
  width: 100%;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 9999;
  visibility: hidden;
  transform: translate3d(0, 100%, 0);
  transform-origin: center;
  transition: all 0.3s ease-in-out;
  // background: #eaeaec;
  min-height: 100rpx;
}
 
.tui-actionsheet-show {
  transform: translate3d(0, 0, 0);
  visibility: visible;
}
.regional-selection {
    text-align: center;
  height: 600rpx;
  background: #fff;
      border-radius: 6rpx;
}
.tui-actionsheet-mask {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  // background: rgba(0, 0, 0, 0.6);
  z-index: 9996;
  transition: all 0.3s ease-in-out;
  opacity: 0;
  visibility: hidden;
}
 
.tui-mask-show {
  opacity: 1;
  visibility: visible;
}
</style>